﻿using Mozhi.Abp.Core.Networks;
using Mozhi.Abp.Domain.BasicData;
using Mozhi.Abp.Domain.BasicData.Repositories;
using Mozhi.Abp.Infrastructure.RemoteRepositories;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Mozhi.Abp.Domain.Repository.BasicData.RemoteRepositories
{
    public class NumberGeneratorRepository : RemoteRepository<NumberGenerator>, INumberGeneratorRepository
    {
        public NumberGeneratorRepository(IRemoteServiceClient remoteServiceClient) : base(remoteServiceClient, "BasicData", "api/v1/number-rules/documents/generate-number")
        {
        }

        public async Task<NumberGenerator> GetAsync(int documentType, string current)
        {
            if (_url.IsNullOrEmpty())
                throw new ArgumentNullException("url");

            var url = $"{_url}?type={documentType}&currentNumber={current}";

            var entity = await _remoteServiceClient.GetAsync<NumberGenerator>(_serviceName, url);

            return entity;
        }
    }
}
